package com.bosssoft.trainee.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liuqiang
 * @date 2022/7/3 19:22
 */

@RestController
@Slf4j

public class TestController {
    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/testA")
    public Map<String,Object> testA() {
        Map<String,Object> map = new HashMap<>();
        map.put("code",200);
        map.put("data","{c语言中文网提醒您，服务访问成功------testA}");
        map.put("message","操作成功");
        return map;
    }

    @GetMapping("/testB")
    @SentinelResource(value = "testCbyAnnotation") //通过注解定义资源
    public String testB() {
        return "c语言中文网提醒您，服务访问成功------testB";
    }
}
